package com.viphuli.http.bean.part;

import android.content.Context;

import com.google.gson.annotations.SerializedName;
import com.offroader.utils.DateUtils;
import com.offroader.utils.StringUtils;
import com.viphuli.app.R;
import com.viphuli.common.Constants;
import com.viphuli.common.MyApp;
import com.viphuli.util.CommonUtils;

public class PurchaseOrder {

	@SerializedName("order_id")
	private String orderId;

	@SerializedName("name")
	private String name;

	@SerializedName("create_time")
	private long createTime;

	@SerializedName("service_time")
	private long serviceTime;

	/** 服务时长(以分为单位) */
	@SerializedName("service_duration")
	private long serviceDuration;

	@SerializedName("address")
	private String address;

	@SerializedName("better_address")
	private String betterAddress;

	@SerializedName("status")
	private int status;

	@SerializedName("price")
	private int price;

	@SerializedName("pay_price")
	private int payPrice;

	@SerializedName("tel")
	private String tel;

	@SerializedName("remark")
	private String remark;

	@SerializedName("service_item_id")
	private int serviceItemId;

	@SerializedName("person_contact")
	private String personContact;

	@SerializedName("service_type")
	private int serviceType;

	@SerializedName("pay_type")
	private int payType;

	@SerializedName("ticket")
	private PurchasePayTicket ticket;

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public long getServiceTime() {
		return serviceTime;
	}

	public void setServiceTime(long serviceTime) {
		this.serviceTime = serviceTime;
	}

	public long getServiceDuration() {
		return serviceDuration;
	}

	public void setServiceDuration(long serviceDuration) {
		this.serviceDuration = serviceDuration;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public int getServiceItemId() {
		return serviceItemId;
	}

	public void setServiceItemId(int serviceItemId) {
		this.serviceItemId = serviceItemId;
	}

	public String getBetterAddress() {
		return betterAddress;
	}

	public void setBetterAddress(String betterAddress) {
		this.betterAddress = betterAddress;
	}

	public String getPersonContact() {
		return personContact;
	}

	public void setPersonContact(String personContact) {
		this.personContact = personContact;
	}

	public int getPayPrice() {
		return payPrice;
	}

	public void setPayPrice(int payPrice) {
		this.payPrice = payPrice;
	}

	public int getServiceType() {
		return serviceType;
	}

	public void setServiceType(int serviceType) {
		this.serviceType = serviceType;
	}

	public PurchasePayTicket getTicket() {
		return ticket;
	}

	public void setTicket(PurchasePayTicket ticket) {
		this.ticket = ticket;
	}

	public int getPayType() {
		return payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	/**
	 * *******************************
	 * 富血模型，为Bean赋予了鲜活的生命
	 * *******************************
	 */
	public String status() {

		Context ctx = MyApp.getInstance();
		String showStatus = null;

		switch (status) {
		case Constants.ORDER_STATUS_WAIT_PAY:
			showStatus = ctx.getString(R.string.text_order_status_wait_pay);
			break;
		case Constants.ORDER_STATUS_WAIT_SERVICE:
			showStatus = ctx.getString(R.string.text_order_status_wait_service);
			break;
		case Constants.ORDER_STATUS_WAIT_ACCEPT:
			showStatus = ctx.getString(R.string.text_order_status_wait_accept);
			break;
		case Constants.ORDER_STATUS_WAIT_COMMENT:
			showStatus = ctx.getString(R.string.text_order_status_wait_comment);
			break;
		case Constants.ORDER_STATUS_ALREADY_CANCEL:
			showStatus = ctx.getString(R.string.text_order_status_already_cancel);
			break;
		case Constants.ORDER_STATUS_ALREADY_COMMENT:
			showStatus = ctx.getString(R.string.text_order_status_already_comment);
			break;

		default:
			showStatus = ctx.getString(R.string.text_order_status_unknow);
			break;
		}

		return showStatus;
	}

	public String createTimeDay() {
		return DateUtils.formatDay(createTime);
	}

	public String createTimeMinute() {
		return DateUtils.formatMinute(createTime);
	}

	public String serviceTimeMinute() {
		return DateUtils.formatMinute(serviceTime);
	}

	public String price() {
		return CommonUtils.convertPrice(price);
	}

	public String payPrice() {
		return CommonUtils.convertPrice(payPrice);
	}

	public String serviceDuration() {
		String unit = MyApp.getInstance().getString(R.string.str_service_duration_unit);
		return serviceDuration + unit;
	}

	public String address() {
		StringBuilder sb = new StringBuilder();

		if (StringUtils.isNotBlank(address)) {
			sb.append(address);
		}

		if (StringUtils.isNotBlank(betterAddress))
			sb.append(betterAddress);

		return sb.toString();
	}

}
